<?

JCAT_Package::ImportClass('JCAT_ViewGtk',JCAT::PACKAGE_MVCGTK) ;

class ViewBaseView extends JCAT_ViewGtk implements JCAT_IViewForm
{
	/**
	 * 控件基本信息
	 * 
	 * @access	public
	 * @param	$aParent=null	JCAT_ViewGtk		拥有此视图的对象
	 * @param	$aUI=null		JCAT_UIGtkGlade		模版引擎
	 * @return	array
	 */
	public function ViewBaseView( JCAT_IViewContainer $aParent, JCAT_UIGtkGlade $aUI=null )
	{
		$this->JCAT_ViewGtk('ViewBaseView','ViewBaseView','ViewBaseView',$aParent,$aUI) ;

		// 创建 并 初始化 UICtrl ---------------------------
		$sUICtrlDir = dirname(__FILE__).'/Instance.UICtrls' ;
		$this->AddUICtrl(JCAT_Package::ImportInstance('ViewName',$sUICtrlDir),'ViewName') ;
		$this->AddUICtrl(JCAT_Package::ImportInstance('ViewPath',$sUICtrlDir),'ViewPath') ;
		$this->AddUICtrl(JCAT_Package::ImportInstance('ImplementsIViewForm',$sUICtrlDir),'ImplementsIViewForm') ;
	}

	
	/**
	 * what's this
	 * 
	 * @access	public
	 * @param	$sPath		string			what's this
	 * @return	void
	 */
	public function SetPath($sPath)
	{
		JCAT_ASSERT::ASSERT_PATH($sPath) ;

		$aUICtrl = $this->GetUICtrl('ViewPath') ;
		$aUICtrl->SetDataByExchange($sPath) ;
	}
	
	public function OnEntViewNameChanged()
	{
		$aUICtrlPath = $this->GetUICtrl('ViewPath') ;
		$sPath = $aUICtrlPath->GetExchangeData() ;
		$sPath = trim($sPath) ;
		if(!$sPath)
		{
			return ;
		}
		
		// 目录
		if( is_dir($sPath) )
		{
			$sDirectory = JCAT_Global::TidyPath($sPath) ;
		}
		
		else
		{
			$sDirectory = JCAT_Global::TidyPath(dirname($sPath)) ;
		}
		
		// 视图名称
		$sName = $this->GetUICtrlExchangeData('ViewName') ;
		$sName = trim($sName) ;
		
		if($sName)
		{
			$sNewPath = "{$sDirectory}class.{$sName}.php" ;
		}
		
		else 
		{
			$sNewPath =& $sDirectory ;
		}
		
		// 新内容
		$aUICtrlPath->SetDataByExchange($sNewPath) ;
	}
}

JCAT_Package::ImportInterface('JCAT_IViewForm',JCAT::PACKAGE_MVC) ;

?>